/*
--------------------------------------------------------------------------------
	This do file creates Tables S1 and S2 from the Supplementary Information of the paper
	"Lies in politics: A study of politicians' preferences for truth-telling".
	Before running this do file, readers should update the directory below 
	called "Home" to where the "ReplicationPackage" folder is located.
	
	Paper: "Lies in politics: A study of politicians' preferences for truth-telling"
	Authors: Katharina A. Janezic, Aina Gallego
	Corresponding author: Aina Gallego, agallego@ibei.org
	
	Last changed: June 6, 2020
--------------------------------------------------------------------------------
*/

*----- 0: Housekeeping
clear all
version 13
set more off

*------------------------------------------------------------------------------*
/* PLEASE UPDATE THE DIRECTORY HERE */
/* For Mac Users */
//cd "Users/.../Replication/code"

/* For Windows Users */
//cd "C:\...\Replication\code"
*------------------------------------------------------------------------------*


*------------------------------------------------------------------------------*
*----- 0: Load data
use "./dataRepl.dta"


*------------------------------------------------------------------------------*
*----- 1: Table S1
// Display results for Table S1, "survey sample" column
// Please note that variables isUni, isNatParty, pop and turnout have been omitted for data protection reasons
// Please also note that due to the standardization of log_pop and age for data protection reasons, the mean values differ compared to those reported in S1
//sum gender age isUni isMajorParty isNatParty pop log_pop turnout // code for original table
sum gender age isMajorParty pop_log // partial column "survey sample", Table S1

// Averages for full sample (column "all municipalities", Table S1):
* gender: 22.13%
* age: 50.47
* isUni: 64.15%
* isMajorParty: 56.6%
* isNatParty: 69.6%
* pop: 18,891.69
* log(pop): 8.923576
* turnout:69.31%


// Test for significant differences between survey sample & full population means
ttest gender==.2212971
ttest age==50.47374 //rejects H0
//ttest isUni==.6414675
ttest isMajorParty=.5657318
//ttest isNatParty=.6964286
//ttest pop=18891.69 //rejects H0
ttest pop_log=8.923576 //rejects H0
//ttest turnout==.6931376



*------------------------------------------------------------------------------*
*----- 2: Table S2

/*
// Replicating Table S2 would require data that reveals the identity of the subjects 
who participated in the survey. To comply with data protection regulation, we
can therefore not provide this data, here.


// Out of sample prediction exercise
reg iscara age gender log_pop isUni isMajorParty isNatParty turnout if answeredSurvey ==1
qui est store reg_ests
qui predict iscara_hat if answeredSurvey ==0
egen iscara_hat_mean = mean(iscara_hat)

logit iscara age gender log_pop isUni isMajorParty isNatParty turnout if answeredSurvey ==1
qui est store logit_ests
qui predict iscara_hat_logit if answeredSurvey ==0
egen iscara_hat_logit_mean = mean(iscara_hat_logit)

* summarise results
sum iscara
sum iscara_hat
sum iscara_hat_logit

* test for statistical difference
ttest iscara=iscara_hat_mean
ttest iscara=iscara_hat_logit_mean


